#include "stdafx.h"
#include "ThreadPool.h"

using namespace syncLib;

class TestTask : public ITask
{
public:

    TestTask(int id) :
        id_(id){}

    virtual void Run()
    {
        std::cout << "[th:" << GetCurrentThreadId() << "]  [task id:" << id_ << " ::  works" << std::endl;
        Sleep(100);
    }

private:
    int id_;
};

void ThreadPoolTest()
{
    ThreadPool tPool(8);

    const int MAX_ITERATIONS = 20;

    for (int i = 0; i < MAX_ITERATIONS; ++i)
    {
        tPool.ScheduleTask(new TestTask(i));
    }

    tPool.WaitForDone();
}
